Parent Obj

I have an easy question. I have one parent object that is the object current from where I'm running the script. This parent have child objects, so I did a "for" to the dxl run a routine to each child below that parent.

But for some reason the "for" isn't working. I even did a print to see where the problem is, maybe it was in the function, but no, when I did the print it didn't even get to the function.

But when I run the "for" logic outside the bigger dxl it work.

What I'm not seeing?

 

void groupSet(DBE calledFrom) {
 
Object po = current
 
 
if(!canModify(reqmtObj)){
infoBox "Open module as Shareable or Exclusive Edit."
return false
}
 
for reqmtObj in po do {
print "dois" 
    SetAll()
    save()
   }
}

braolive - Tue Apr 08 17:05:45 EDT 2014

Re: Parent Obj
Mike.Scharnow - Tue Apr 08 17:29:53 EDT 2014

Is reqmtObj defined as "Object"? Is po really the correct object?

Not sure, what "SetAll()" does, may be it changes the current object?

Not sure what you want to do with the "save()". Is this "trigEvent_ save ()". If you want do "save (current Module)" you should do it outside the loop. Or is save() a function you overrode?

Is there a filter defined, so that you cannot see the child objects?

try adding

print number(reqmtObj) " - " print number (po) "\n";

BR,
Mike 

Re: Parent Obj
llandale - Thu Apr 10 13:50:49 EDT 2014

"po = current" means that it will get the Object that is current in the current Module, at that time.  It is probably getting set correctly but you need to be careful and mindful when using "current".  I would add the following:

  • print "in groupSet(), po = " identifier(po) "\t" number(po) "\n"

Inside your loop, do this:

  • print "in groupSet(), reqmtObj = " identifier( reqmtObj) "\t" number(reqmtObj) "\n"

Sure seems to me you need to send " reqmtObj" to function "SetAll()", and perhaps "save()" depending on what they do.  As coded, it seems "SetAll()" probably also gets the "current" object, which is repeatedly "po" not its children reqmtObj.

Your "if(!canModify(reqmtObj)){" check should be lower inside your loop.

Since function groupSet is type "void", you should just "return" and will get a DXL error if "return(false)" gets executed.

Turn off Autodeclare_ and declare your local variables inside your local functions.  Use global variables sparingly.  As it is, "reqmtObj" may be defined or implied as a variable of type other than "Object" in code above the code you posted.

-Louie